Program purpose

This program will map a community district in green, add census blocks with red border, and place text inside the border.

Load key functions

Running annotate-maps.R will create some useful functions.

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.6     v dplyr   1.0.8
## v tidyr   1.2.0     v stringr 1.4.0
## v readr   2.1.2     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
run_tests <- TRUE # allow simple function tests
terse <- FALSE # display information on intermediate steps
source("annotate-maps.R") # load several functions
## 
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
## 
##     set_names
## The following object is masked from 'package:tidyr':
## 
##     extract
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
## Warning: package 'tidycensus' was built under R version 4.1.3
## 
## 
## Testing conditional_glimpse
## 
## 
## 
## test1
## 
## Rows: 3
## Columns: 2
## $ x <int> 1, 2, 3
## $ y <int> 4, 5, 6
## 
## 
## 
## 
## Testing plot_green
## 
## 
## 
## jackson
## 
## Rows: 1
## Columns: 19
## $ STATEFP  <chr> "29"
## $ COUNTYFP <chr> "095"
## $ COUNTYNS <chr> "00758502"
## $ GEOID    <chr> "29095"
## $ NAME     <chr> "Jackson"
## $ NAMELSAD <chr> "Jackson County"
## $ LSAD     <chr> "06"
## $ CLASSFP  <chr> "H1"
## $ MTFCC    <chr> "G4020"
## $ CSAFP    <chr> "312"
## $ CBSAFP   <chr> "28140"
## $ METDIVFP <chr> NA
## $ FUNCSTAT <chr> "A"
## $ ALAND    <dbl> 1565698757
## $ AWATER   <dbl> 30621016
## $ INTPTLAT <chr> "+39.0053640"
## $ INTPTLON <chr> "-094.3432105"
## $ geometry <MULTIPOLYGON [°]> MULTIPOLYGON (((-94.21774 3...
## $ label    <chr> "Jackson"
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
## 
## 
## Testing find_bg
## 
## Simple feature collection with 1 feature and 3 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -94.4982 ymin: 39.12037 xmax: -94.39993 ymax: 39.19495
## Geodetic CRS:  NAD83
##          bg_id       bg_name  bg_area                       geometry
## 1 290470222003 Block Group 3 44049569 POLYGON ((-94.49816 39.1513...
## 
## 
## Testing find_bl
## 
## Simple feature collection with 87 features and 3 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -94.4982 ymin: 39.12589 xmax: -94.39993 ymax: 39.19495
## Geodetic CRS:  NAD83
## First 10 features:
##              bl_id    bl_name     bl_area                       geometry
## 1  290470222003000 Block 3000 1443109.779 POLYGON ((-94.42512 39.1900...
## 2  290470222003001 Block 3001  342535.398 POLYGON ((-94.42448 39.1895...
## 3  290470222003002 Block 3002  128804.084 POLYGON ((-94.43346 39.1936...
## 4  290470222003003 Block 3003  201124.292 POLYGON ((-94.44703 39.1819...
## 5  290470222003004 Block 3004 1248947.147 POLYGON ((-94.44583 39.1823...
## 6  290470222003005 Block 3005  163073.045 POLYGON ((-94.43484 39.1826...
## 7  290470222003006 Block 3006   42366.067 POLYGON ((-94.43395 39.1829...
## 8  290470222003007 Block 3007  108120.151 POLYGON ((-94.4266 39.18765...
## 9  290470222003008 Block 3008    9491.135 POLYGON ((-94.42665 39.1879...
## 10 290470222003009 Block 3009    1272.300 POLYGON ((-94.42695 39.1875...
## 
## 
## Testing align_tx
## 
## # A tibble: 1 x 6
## # Groups:   bg_id [1]
##   bg_id        cd_id people_in units_in people units
##   <chr>        <dbl>     <dbl>    <dbl>  <dbl> <dbl>
## 1 290470222003   117       315      107    768   302
## 
## 
## Testing download_acs
## 
## # A tibble: 2 x 3
##   name       label                                    concept   
##   <chr>      <chr>                                    <chr>     
## 1 B01001_003 Estimate!!Total:!!Male:!!Under 5 years   SEX BY AGE
## 2 B01001_027 Estimate!!Total:!!Female:!!Under 5 years SEX BY AGE
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS

## # A tibble: 3,368 x 5
##    GEOID        NAME                                     variable estimate   moe
##    <chr>        <chr>                                    <chr>       <dbl> <dbl>
##  1 200910500001 Block Group 1, Census Tract 500, Johnso~ B01001_~        0    11
##  2 200910500001 Block Group 1, Census Tract 500, Johnso~ B01001_~       50    49
##  3 200910500002 Block Group 2, Census Tract 500, Johnso~ B01001_~       21    15
##  4 200910500002 Block Group 2, Census Tract 500, Johnso~ B01001_~       18    17
##  5 200910500003 Block Group 3, Census Tract 500, Johnso~ B01001_~       28    16
##  6 200910500003 Block Group 3, Census Tract 500, Johnso~ B01001_~       14    11
##  7 200910500004 Block Group 4, Census Tract 500, Johnso~ B01001_~       36    22
##  8 200910500004 Block Group 4, Census Tract 500, Johnso~ B01001_~        8     9
##  9 200910500005 Block Group 5, Census Tract 500, Johnso~ B01001_~       19    25
## 10 200910500005 Block Group 5, Census Tract 500, Johnso~ B01001_~        0    11
## # ... with 3,358 more rows

Load key data

Key RData files are:

bg

path_name <- "../data/"
load(glue("{path_name}bg.RData"))
conditional_glimpse(bg)
## 
## 
## bg
## 
## Rows: 1,684
## Columns: 4
## $ bg_id    <chr> "201039819003", "201030714004", "201030711041", "201030712051~
## $ bg_name  <chr> "Block Group 3", "Block Group 4", "Block Group 1", "Block Gro~
## $ bg_area  <dbl> 984975.5, 36602869.0, 18313082.5, 26007918.3, 11448660.8, 243~
## $ geometry <POLYGON [°]> POLYGON ((-94.94756 39.3373..., POLYGON ((-95.18756 3~

cd

path_name <- "../data/"
load(glue("{path_name}cd.RData"))
conditional_glimpse(cd)
## 
## 
## cd
## 
## Rows: 59
## Columns: 4
## $ cd_id    <dbl> 106, 108, 113, 102, 129, 116, 114, 101, 105, 103, 107, 109, 1~
## $ cd_name  <chr> "East Side", "Old Northeast", "Greater Downtown", "Blue Valle~
## $ cd_area  <dbl> 281713850, 118237219, 181920811, 216842678, 412671242, 264282~
## $ geometry <POLYGON [°]> POLYGON ((-94.52337 39.0941..., POLYGON ((-94.50777 3~

cd-intersections

path_name <- "../data/"
load(glue("{path_name}cd-intersections.RData"))
conditional_glimpse(bg_cd_intersection)
## 
## 
## bg_cd_intersection
## 
## Rows: 1,236
## Columns: 3
## $ bg_id      <chr> "290950161001", "290950166002", "290950060001", "2909500340~
## $ cd_id      <dbl> 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,~
## $ bg_prop_in <dbl> 0.8919314491, 1.0000000000, 1.0000000000, 1.0000000000, 0.3~
# cd-intersections.RData also contains
# information at the block and tract
# levels

cd-weights

path_name <- "../data/"
load(glue("{path_name}cd-weights.RData"))
# merge with bg_cd_intersection to get
# bg_prop_in
bg_counts                             %>%
  inner_join(
    bg_cd_intersection, 
    by=c("bg_id", "cd_id"))           %>%
  mutate(
    bg_prop_in=round(100*bg_prop_in)) %>%
  mutate(
    short_id=str_sub(bg_id, 6, 12))    -> bg_counts
conditional_glimpse(bg_counts)
## 
## 
## bg_counts
## 
## Rows: 1,236
## Columns: 8
## Groups: bg_id [776]
## $ bg_id      <chr> "200910500001", "200910500002", "200910500003", "2009105010~
## $ cd_id      <dbl> 209, 209, 209, 209, 211, 209, 211, 211, 112, 112, 112, 111,~
## $ people_in  <dbl> 1, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,~
## $ units_in   <dbl> 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,~
## $ people     <dbl> 744, 695, 751, 1313, 1313, 1196, 643, 630, 778, 961, 1210, ~
## $ units      <dbl> 341, 311, 377, 648, 648, 549, 315, 444, 287, 335, 461, 430,~
## $ bg_prop_in <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,~
## $ short_id   <chr> "0500001", "0500002", "0500003", "0501001", "0501001", "050~
# cd-weights.RData also contains bl_counts

Select interesting cds

name_list <- c(
  "Brookside",
  "Midtown",
  "Swope Park",
  "Waldo",
  "Ward Parkway",
  "Greater Downtown",
  "Antioch",
  "Little Blue Valley",
  "Rosedale",
  "Argentine")

cd                                     %>%
  filter(cd_name %in% name_list)       %>%
  pull(cd_id)                           -> interesting_cd

Check out bg_prop_in

for(i_cd in sort(cd$cd_id)) {
  # create subsets
  cd0 <- filter(cd, cd_id==i_cd)
  bg0 <- find_bg(i_cd)
  bg0$bg_area <- round(bg0$bg_area/(10^6), 2)
  bg_text <- align_tx(bg0, bg_counts, i_cd)
  bg0$short_id <- str_sub(bg0$bg_id, 6, 12)

  # loop for text variables found in bg_text
  for (v in c("bg_prop_in")) {
    ti <- glue("{v} for {cd0$cd_name} ({cd0$cd_id})")
    plot_green(cd0, bg0, bg_text[[v]]) +
      ggtitle(ti)                        -> bg_plot
    plot(bg_plot)
  }
}
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Get counts of people and units

Look only at interesting community districts and focus only on those block groups that have more than 5% of their area inside the community district.

for(i_cd in interesting_cd) {
  # create subsets
  cd0 <- filter(cd, cd_id==i_cd)
  bg0 <- find_bg(i_cd, lo=0.05)
  bg0$bg_area <- round(bg0$bg_area/(10^6), 2)
  bg_text <- align_tx(bg0, bg_counts, i_cd)
  bg0$short_id <- str_sub(bg0$bg_id, 6, 12)

  # loop for text variables found in bg_text
  for (v in c(
      "short_id", 
      "people", 
      "units")) {
    ti <- glue("{v} for {cd0$cd_name} ({cd0$cd_id})")
    plot_green(cd0, bg0, bg_text[[v]]) +
      ggtitle(ti)                        -> bg_plot
    plot(bg_plot)
  }
}
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Get counts of children 5 and under

for(i_cd in interesting_cd) {
  # create subsets
  cd0 <- filter(cd, cd_id==i_cd)
  bg0 <- find_bg(i_cd, lo=0.05)
  vlist <- c("B01001_003", "B01001_027")
  acs_kids <- download_acs(vlist)
  acs_kids                            %>%
    group_by(GEOID)                   %>%
    summarize(acs_kids=sum(estimate)) %>%
    rename(bg_id=GEOID)                -> acs_kids
  conditional_glimpse(acs_kids)
  bg_text <- align_tx(acs_kids, bg0, i_cd)
  conditional_glimpse(bg_text)

  # loop for text variables found in acs_text
  for (v in c("acs_kids")) {
    ti <- glue("{v} for {cd0$cd_name} ({cd0$cd_id})")
    plot_green(cd0, bg0, bg_text[[v]]) +
      ggtitle(ti)                        -> bg_plot
    plot(bg_plot)
  }
}
## # A tibble: 2 x 3
##   name       label                                    concept   
##   <chr>      <chr>                                    <chr>     
## 1 B01001_003 Estimate!!Total:!!Male:!!Under 5 years   SEX BY AGE
## 2 B01001_027 Estimate!!Total:!!Female:!!Under 5 years SEX BY AGE
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## Getting data from the 2016-2020 5-year ACS
## 
## 
## acs_kids
## 
## Rows: 1,684
## Columns: 2
## $ bg_id    <chr> "200910500001", "200910500002", "200910500003", "200910500004~
## $ acs_kids <dbl> 50, 39, 42, 44, 19, 136, 196, 86, 65, 87, 38, 133, 150, 64, 1~
## Error in `stopifnot()`:
## ! Problem while computing `..1 = cd_id == i_cd`.
## Caused by error:
## ! object 'cd_id' not found

```